unit UMovParametrizaEmpreendimento;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, StdCtrls, Buttons, Gauges, Mask, DBCtrls, UDptoUteis,
  ExtCtrls;

type
  TFMovParametrizaEmpreendimento = class(TForm)
    BT1: TBitBtn;
    QBLOCO: TQuery;
    EdCodEmpreendimento: TEdit;
    lbl1: TLabel;
    EdDescEmpreendimento: TEdit;
    QGenerica: TQuery;
    Panel1: TPanel;
    Panel2: TPanel;
    gModeloEtapa: TGauge;
    gModeloBloco: TGauge;
    lblModeloEtapa: TLabel;
    lblModeloBloco: TLabel;
    Panel3: TPanel;
    gBloco: TGauge;
    lblBloco: TLabel;
    Panel4: TPanel;
    QBLOCOEMPBLODESCRICAO: TStringField;
    QBLOCOEMPREENDID: TIntegerField;
    QBLOCOEMPBLOID: TIntegerField;
    QBLOCOEMPBLOQTD: TIntegerField;
    lbl2: TLabel;
    dbedtEMPBLOID: TDBEdit;
    ds1: TDataSource;
    lbl8: TLabel;
    dbedtEMPBLOQTD: TDBEdit;
    lbl9: TLabel;
    dbedtEMPBLODESCRICAO: TDBEdit;
    Panel5: TPanel;
    QBlocoModelo: TQuery;
    intgrfldQBlocoModeloEMPREENDID: TIntegerField;
    intgrfldQBlocoModeloEMPBLOID: TIntegerField;
    intgrfldQBlocoModeloMODID: TIntegerField;
    ds2: TDataSource;
    lbl5: TLabel;
    dbedtMODID: TDBEdit;
    Edit4: TEdit;
    Panel6: TPanel;
    QEMPPARAM: TQuery;
    dtmfldQEMPPARAMEMPPARAMDTFIM: TDateTimeField;
    dtmfldQEMPPARAMEMPPARAMDTINI: TDateTimeField;
    dtmfldQEMPPARAMEMPPARAMDTPREVFIM: TDateTimeField;
    dtmfldQEMPPARAMEMPPARAMDTPREVINI: TDateTimeField;
    intgrfldQEMPPARAMMODETPID: TIntegerField;
    intgrfldQEMPPARAMMODID: TIntegerField;
    intgrfldQEMPPARAMEMPBLOID: TIntegerField;
    intgrfldQEMPPARAMEMPREENDID: TIntegerField;
    ds3: TDataSource;
    lbl6: TLabel;
    dbedtEMPPARAMDTPREVFIM: TDBEdit;
    lbl7: TLabel;
    dbedtEMPPARAMDTPREVINI: TDBEdit;
    lbl3: TLabel;
    dbedtMODETPID: TDBEdit;
    Edit1: TEdit;
    BTModeloEtapa: TBitBtn;
    Panel7: TPanel;
    gEtapaMaterial: TGauge;
    lblEtapaMaterial: TLabel;
    Panel8: TPanel;
    BTEtapaMaterial: TBitBtn;
    QEtapaMaterial: TQuery;
    fltfldQEtapaMaterialEMPREENDMATVLRPREVISTO: TFloatField;
    intgrfldQEtapaMaterialIDMATERIAL: TIntegerField;
    intgrfldQEtapaMaterialEMPREENDID: TIntegerField;
    lbl4: TLabel;
    dbedtEMPREENDMATVLRPREVISTO: TDBEdit;
    ds4: TDataSource;
    lbl10: TLabel;
    dbedtIDMATERIAL: TDBEdit;
    lbl11: TLabel;
    dbedtEMPREENDID: TDBEdit;
    procedure BT1Click(Sender: TObject);
    procedure EdCodEmpreendimentoExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMovParametrizaEmpreendimento: TFMovParametrizaEmpreendimento;

implementation

{$R *.dfm}

procedure TFMovParametrizaEmpreendimento.BT1Click(Sender: TObject);
begin
  QBLOCO.Close;
  QBLOCO.SQL.Clear;
  QBLOCO.SQL.Add('SELECT EMPBLOID FROM EMPREENDIMENTOBLOCO'
                    + ' WHERE EMPREENDID = ' + QuotedStr(EdCodEmpreendimento.Text) );
  QBLOCO.Open;
  QBLOCO.First;

  gBloco.MaxValue := QBLOCO.RecordCount;
  gBloco.Progress := 1;
  lblBloco.Caption := '1/' + inttostr(gBloco.MaxValue);
  // FIM - BLOCO

  // INICIO BLOCO MODELO
  QBlocoModelo.CLOSE;
  QBlocoModelo.SQL.Clear;
  QBlocoModelo.SQL.Add('SELECT MODID FROM EMPREENDIMENTOBLOCOMODELO '
                    + ' WHERE EMPREENDID = ' + QuotedStr(EdCodEmpreendimento.Text)
                    + ' AND EMPBLOID = ' + QuotedStr(QBLOCO.FIELDBYNAME('EMPBLOID').AsString ));

  QBlocoModelo.Open;
  QBlocoModelo.First;
  gModeloBloco.MaxValue := QBlocoModelo.RecordCount;
  gModeloBloco.Progress := 1;
  lblModeloBloco.Caption := '1/' + inttostr(gModeloBloco.MaxValue);

end;

procedure TFMovParametrizaEmpreendimento.EdCodEmpreendimentoExit(Sender: TObject);
begin
  QGenerica.Close;
  QGenerica.SQL.Clear;
  QGenerica.SQL.Add('SELECT MODID, EMPREENDDESCRICAO FROM EMPREENDIMENTO WHERE EMPREENDID = ' + QuotedStr(EdCodEmpreendimento.Text));
  QGenerica.Open;

end;

end.
